const rule = {
    company_id: [{ required: true, message: "请输入公司ID", trigger: "blur" }],
    parent_id: [{ required: true, message: "请选择父级表计", trigger: "change" }],
    engine_id: [
        { required: true, message: "请选择引擎", trigger: "change" },
        {
            type: "number",
            message: "引擎ID必须为数字",
            trigger: ["change", "blur"],
        },
    ],
    standard_coal_factor: [
        { required: true, message: "请输入折标煤系数", trigger: "blur" },
        {
            pattern: /^\d+(\.\d+)?$/,
            message: "请输入有效的数值",
            trigger: "blur",
        },
    ],
    meter_code: [{ required: true, message: "请输入表计编码", trigger: "blur" }],
    meter_id: [
        {
            required: true,
            message: "请输入表计公式或外部表计ID",
            trigger: "blur",
        },
    ],
    installation_date: [
        { required: true, message: "请选择安装日期", trigger: "change" },
    ],
    status: [{ required: true, message: "请选择状态", trigger: "change" }],
    remarks: [{ required: false }],
    type: [{ required: true, message: "请选择类型", trigger: "change" }],
    bottom_value: [
        { required: false },
        {
            type: "number",
            message: "启表底数必须为数字",
            trigger: ["change", "blur"],
        },
    ],
    multiple: [
        { required: false },
        {
            type: "number",
            message: "倍率必须为数字",
            trigger: ["change", "blur"],
        },
    ],
    // 添加新字段的验证规则
    meter_name: [{ max: 20, message: '表计名称长度不能超过20个字符', trigger: 'blur' }],
    cell: [{ max: 100, message: '楼栋长度不能超过100个字符', trigger: 'blur' }],
    important_device_name: [
        { required: (form) => form.is_important_device, message: '请输入重点设备名称', trigger: 'blur' },
        { max: 100, message: '设备名称长度不能超过100个字符', trigger: 'blur' }
    ],
    new_energy: [
        { required: (form) => form.elec_generate === 1, message: '请输入新能源类型', trigger: 'blur' },
        { max: 50, message: '新能源类型长度不能超过50个字符', trigger: 'blur' }
    ]
};

export default rule;